package com.th.controller;

import com.th.common.response.CommonResponse;
import com.th.common.vo.LoginUserVo;
import com.th.config.web.BaseController;
import com.th.service.UsUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.TreeMap;

/**
 * @Author tuhang
 * @PackageName nswcy-crowdsource-client-server
 * @Package com.th.controller
 * @Date 2023/6/7 15:46
 * @Version 1.0
 */
@RestController
@Api(tags = "认证授权接口")
public class AuthLoginController extends BaseController {


    @Resource
    private UsUserService userService;

    /**
     * 邮件登录 / 短信登录 / 验证码
     * @param loginUserVo
     * @return
     */
    @PostMapping("/login")
    public CommonResponse<String> login(@RequestBody LoginUserVo loginUserVo){
       return CommonResponse.success(userService.login(loginUserVo.getUsername(),loginUserVo.getPassword()));
    }

    /**
     * 退出
     * @return
     */
    @PostMapping("/logout")
    public Boolean logout(@RequestHeader("token") String token){
        return userService.logout(token);
    }

}
